package com.pdg.android.splorr.data.enums;

import com.pdg.android.splorr.R;
import com.pdg.android.splorr.states.UICommand;

public enum DoorState {
	WALL(false,R.array.door_states,0,UICommand.SEARCH_WALL,UICommand.MARK_WALL,0),
	PASSAGEWAY(true,R.array.door_states,1,UICommand.MOVE,UICommand.MARK_WALL,1),
	CLOSED_DOOR(false,R.array.door_states,2,UICommand.OPEN_DOOR,UICommand.MARK_WALL,0),
	OPEN_DOOR(true,R.array.door_states,3,UICommand.MOVE,UICommand.CLOSE_DOOR,1),
	LOCKED_DOOR(false,R.array.door_states,4,UICommand.UNLOCK_DOOR,UICommand.EXAMINE_LOCK,0),
	SECRET_DOOR(false,R.array.door_states,0,UICommand.SEARCH_WALL,UICommand.MARK_WALL,0),
	LOCKED_SECRET_DOOR(false,R.array.door_states,0,UICommand.SEARCH_WALL,UICommand.MARK_WALL,0);
	private boolean passable;
	private int stringArrayId;
	private int arrayIndex;
	private UICommand uiCommand;
	private UICommand secondaryUICommand;
	private int wanderingMonsterCounterValue;
	DoorState(boolean thePassable,int theStringArrayId,int theArrayIndex,UICommand theUICommand,UICommand theSecondaryUICommand,int theWanderingMonsterCounterValue){
		setPassable(thePassable);
		setStringArrayId(theStringArrayId);
		setArrayIndex(theArrayIndex);
		setUICommand(theUICommand);
		setSecondaryUICommand(theSecondaryUICommand);
		setWanderingMonsterCounterValue(theWanderingMonsterCounterValue);
	}
	private void setWanderingMonsterCounterValue(
			int theWanderingMonsterCounterValue) {
		wanderingMonsterCounterValue = theWanderingMonsterCounterValue;
	}
	private void setSecondaryUICommand(UICommand theSecondaryUICommand) {
		secondaryUICommand = theSecondaryUICommand;
	}
	private void setUICommand(UICommand theUICommand) {
		uiCommand = theUICommand;
	}
	private void setArrayIndex(int theArrayIndex) {
		arrayIndex=theArrayIndex;
	}
	public int getArrayIndex(){
		return arrayIndex;
	}
	private void setStringArrayId(int theStringId) {
		stringArrayId = theStringId;
	}
	public int getStringArrayId(){
		return stringArrayId;
	}
	private void setPassable(boolean thePassable) {
		passable = thePassable;
	}
	public boolean isPassable(){
		return passable;
	}
	public UICommand getUICommand(){
		return uiCommand;
	}
	public UICommand getSecondaryUICommand(){
		return secondaryUICommand;
	}
	public int getWanderingMonsterCounterValue(){
		return wanderingMonsterCounterValue;
	}
	public boolean canOpen(){
		return this==CLOSED_DOOR;
	}
	public DoorState open(){
		if(this==CLOSED_DOOR){
			return OPEN_DOOR;
		}else{
			return this;
		}
	}
	public boolean canClose(){
		return this==OPEN_DOOR;
	}
	public DoorState close(){
		if(this==OPEN_DOOR){
			return CLOSED_DOOR;
		}else{
			return this;
		}
	}
	public boolean canHide(){
		switch(this){
		case CLOSED_DOOR:
		case LOCKED_DOOR:
			return true;
		default:
			return false;
		}
	}
	public DoorState hide(){
		switch(this){
		case CLOSED_DOOR:
			return SECRET_DOOR;
		case LOCKED_DOOR:
			return LOCKED_SECRET_DOOR;
		default:
			return this;
		}
	}
	public boolean isHidden(){
		switch(this){
		case LOCKED_SECRET_DOOR:
		case SECRET_DOOR:
			return true;
		default:
			return false;
		}
		
	}
	public DoorState reveal(){
		switch(this){
		case LOCKED_SECRET_DOOR:
			return LOCKED_DOOR;
		case SECRET_DOOR:
			return CLOSED_DOOR;
		default:
			return this;
		}
	}
	public boolean canLock(){
		switch(this){
		case CLOSED_DOOR:
		case SECRET_DOOR:
			return true;
		default:
			return false;
		}
	}
	public DoorState lock(){
		switch(this){
		case CLOSED_DOOR:
			return LOCKED_DOOR;
		case SECRET_DOOR:
			return LOCKED_SECRET_DOOR;
		default:
			return this;
		}
	}
	public boolean canUnlock(){
		switch(this){
		case LOCKED_SECRET_DOOR:
		case LOCKED_DOOR:
			return true;
		default:
			return false;
		}
	}
	public DoorState unlock(){
		switch(this){
		case LOCKED_SECRET_DOOR:
			return SECRET_DOOR;
		case LOCKED_DOOR:
			return CLOSED_DOOR;
		default:
			return this;
		}
	}
	public boolean canFind() {
		switch(this){
		case LOCKED_SECRET_DOOR:
		case SECRET_DOOR:
			return true;
		default:
			return false;
		}
	}
	public DoorState find(){
		switch(this){
		case LOCKED_SECRET_DOOR:
			return LOCKED_DOOR;
		case SECRET_DOOR:
			return CLOSED_DOOR;
		default:
			return this;
		}
	}
}
